﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IntelligentDecisioning.SharePoint.Definition.Fields
{
    public class TextField:Field
    {
        public int Lines { get; set; }
        public int? MaxLength { get; set; }
        public bool StripWhitespace { get; set; }

        public TextField()
        {
            Lines = 1;
        }

        protected override void AddCustomFieldAttributes(System.Xml.XmlWriter xmlWriter)
        {
            base.AddCustomFieldAttributes(xmlWriter);

            xmlWriter.WriteAttributeString(DefinitionConstants.NUMBEROFLINES_ATTRIBUTE, Lines.ToString());

            if (MaxLength.HasValue && MaxLength.Value > 0)
            {
                xmlWriter.WriteAttributeString(DefinitionConstants.MAXLENGTH_ATTRIBUTE, MaxLength.Value.ToString());
            }

            if (StripWhitespace)
            {
                xmlWriter.WriteAttributeString(DefinitionConstants.STRIPWHITESPACE_ATTRIBUTE, DefinitionConstants.TRUE);
            }
        }
    }
}
